﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using NUnit.Framework;
using SJTU.SE.RoughSet.Lib.IO;

namespace SJTU.SE.RoughSet.Test.IO
{
    [TestFixture]
    public class DecisionTableFileInitializerTest
    {
        DecisionTableFileInitializer fileInitializer = new DecisionTableFileInitializer(".\\TestData\\zoo.txt");

        [Test]
        [ExpectedException(typeof(FileNotFoundException))]
        public void Initializer_should_throw_exception_if_file_not_found()
        {
            DecisionTableFileInitializer fileInitializerError = new DecisionTableFileInitializer(".\\TestData\\zoo1.txt");
        }

        [Test]
        [ExpectedException(typeof(InvalidDataException),ExpectedMessage = "Column count error! The 100 row has 18 columns")]
        public void Initializer_should_throw_exception_if_data_file_has_different_column_count()
        {
            DecisionTableFileInitializer fileInitializerError = new DecisionTableFileInitializer(".\\TestData\\zoo2.txt");
        }

        [Test]
        public void Initializer_should_return_right_column_count()
        {
            Assert.AreEqual(17, fileInitializer.ColumnCount);
        }

        [Test]
        public void Initializer_should_return_right_row_count()
        {
            Assert.AreEqual(101, fileInitializer.RowCount);
        }

        [Test]
        public void Initializer_should_return_right_data()
        {
            Assert.AreEqual(1, fileInitializer.GetRawData()[0][0]);
            Assert.AreEqual(2, fileInitializer.GetRawData()[100][16]);
        }

    }
}
